package org.java.enumpack;


/**
 * @author Zhang Guangyong
 * @desacription 枚举操作类实例
 * @date 2019年07月19日 9:53
 */
public enum Operation {


    // 四个枚举值对应下面抽象方法的四个实现
    PLUS {
        public double eval(double a, double b) {        //相当于派生子类
            return a + b;
        }
    },
    MINUS {
        public double eval(double a, double b) {
            return a - b;
        }
    },
    TIMES {
        public double eval(double a, double b) {
            return a * b;
        }
    },
    DIVIDE {
        public double eval(double a, double b) {
            return a / b;
        }
    };

    public abstract double eval(double a, double b);


    public static void main(String[] args) {


        System.out.println(Operation.PLUS.eval(100, 200));
        System.out.println(Operation.MINUS.eval(100, 200));
        System.out.println(Operation.TIMES.eval(100, 200));
        System.out.println(Operation.DIVIDE.eval(100, 200));


    }
}
